/**
 * @file factory_mode_main.c
 *
 */

/*********************
 *      INCLUDES
 *********************/
#include "lv_watch.h"

#if USE_LV_WATCH_FACTORY_MODE!= 0

#include <stdio.h>

/*********************
 *      DEFINES
 *********************/

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 *  STATIC PROTOTYPES
 **********************/
static void factorymode_autotest_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
static void factorymode_testreport_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#if USE_LV_WATCH_FACTORYMODE_AGING_MODE != 0
static void factorymode_agingmode_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#endif
static void factorymode_factoryreset_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#if USE_LV_WATCH_ENGINEER_MODE!= 0
static void factorymode_engineermode_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#endif
#if USE_LV_WATCH_CTA!= 0
static void cta_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#endif
#if USE_LV_WATCH_FACTORYMODE_HWTEST != 0
static void factorymode_hwtest_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#endif
#if USE_LV_WATCH_FACTORYMODE_GCF != 0
static void factorymode_gcf_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
#endif
static void factorymode_main_prepare_destory(lv_obj_t * activity_obj);
static void factorymode_init_style(void);
static void factorymode_init_testmodule(void);

/**********************
 *  STATIC VARIABLES
 **********************/
const struct {
    watchLangTxtId_t txtId;
    lv_event_cb_t event_cb;
} factorymodelist[] = {
    { WATCH_TEXT_ID_AUTO_TEST, factorymode_autotest_create_btn_event_cb },
    { WATCH_TEXT_ID_TEST_REPORT, factorymode_testreport_create_btn_event_cb },
#if USE_LV_WATCH_FACTORYMODE_AGING_MODE != 0
    { WATCH_TEXT_ID_AGING_MODE, factorymode_agingmode_create_btn_event_cb },
#endif
    { WATCH_TEXT_ID_FACTORY_RESET, factorymode_factoryreset_create_btn_event_cb },
#if USE_LV_WATCH_ENGINEER_MODE!= 0
    { WATCH_TEXT_ID_ENGINEER_MODE, factorymode_engineermode_create_btn_event_cb },
#endif
#if USE_LV_WATCH_CTA!= 0
    { WATCH_TEXT_ID_CTA, cta_create_btn_event_cb },
#endif
#if USE_LV_WATCH_FACTORYMODE_GCF != 0
    { WATCH_TEXT_ID_GCF, factorymode_gcf_create_btn_event_cb },
#endif
#if USE_LV_WATCH_FACTORYMODE_HWTEST != 0
    { WATCH_TEXT_ID_PERFORMANCE_TEST, factorymode_hwtest_create_btn_event_cb },
#endif
};

/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
***********************/
lv_obj_t * factorymode_main_create(lv_obj_t * activity_obj)
{
    lv_obj_t * obj;
    if(activity_obj == NULL) {
        lv_watch_activity_ext_t activity_ext;
        memset(&activity_ext, 0, sizeof(lv_watch_activity_ext_t));
        activity_ext.actId = ACT_ID_FACTORY_MODE_MAIN;
        activity_ext.create = factorymode_main_create;
        activity_ext.prepare_destory = factorymode_main_prepare_destory;
        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
        LV_ASSERT_MEM(activity_obj);
        if(NULL == activity_obj) {
            return NULL;
        }
    }

    obj = lv_watch_obj_create(activity_obj);
    LV_ASSERT_MEM(obj);
    if(NULL == obj) {
        return NULL;
    }
    watch_set_suspend_enable(false, ACT_ID_FACTORY_MODE_MAIN, 0);
    /*Allocate the object type specific extended data*/
    lv_factory_obj_ext_t * ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_factory_obj_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    ext->testmode = TEST_MANUAL;
    ext->module = AUTOTEST_MAX;
    ext->label_key_state = NULL;
    ext->buffer = NULL;
    factorymode_init_test_res();
    factorymode_init_style();
    factorymode_init_testmodule();

    lv_obj_t * title = lv_label_create(obj, NULL);
    lv_obj_set_size(title, LV_HOR_RES, LV_VER_RES / 4);
    lv_label_set_text_id(title, WATCH_TEXT_ID_FACTORY_MODE);
    lv_obj_add_style(title, LV_LABEL_PART_MAIN, &lv_watch_font30);
    lv_obj_align(title, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);

    lv_obj_t * list = lv_list_create(obj, NULL);
    lv_watch_obj_add_element(list);
    lv_watch_obj_add_element(lv_page_get_scrl(list));
    lv_coord_t interval = 20;
    lv_obj_set_size(list, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(title) - interval - 10);
    lv_page_set_edge_flash(list, true);
    lv_obj_add_style(list, LV_PAGE_PART_EDGE_FLASH, &lv_watch_cont_opa1);
    lv_obj_align(list, title, LV_ALIGN_OUT_BOTTOM_MID, 0, interval);

    lv_obj_add_style(list, LV_LIST_PART_BG,  &lv_watch_style_transp);

    uint8_t i = 0;
    lv_obj_t * btn;
    lv_obj_t * label;
    uint8_t list_cnt = sizeof(factorymodelist) / sizeof(factorymodelist[0]);
    for(i = 0; i < list_cnt; i++) {
        btn = lv_list_add_btn(list, NULL, lv_lang_get_text(factorymodelist[i].txtId));
        lv_watch_obj_add_element(btn);
        lv_obj_add_style(btn, LV_BTN_PART_MAIN, &(ext->list_btn_st));
        lv_obj_set_event_cb(btn, factorymodelist[i].event_cb);
        label = lv_obj_get_child(btn, NULL);
        lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
        lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
        lv_obj_set_width(label, LV_HOR_RES - 10);
    }

    lv_obj_set_click(list, true);

    return obj;

}

lv_factory_obj_ext_t * factorymode_get_ext(void)
{
    lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN);
    if(activity_obj == NULL) return NULL;

    lv_obj_t * watch_obj;
    lv_watch_get_child_obj(activity_obj, lv_watch_obj_signal, &watch_obj);
    if(watch_obj == NULL) return NULL;

    if(watch_obj) {
        lv_factory_obj_ext_t * ext = lv_obj_get_ext_attr(watch_obj);
        return ext;
    }
    return NULL;
}

void factorymode_init_test_res()
{
    //read from nv
    uint8_t i = 0;
    nv_watch_factorymode_t nv_res;
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    memset(&nv_res, 0, NV_FACTORYMODE_LEN);

    UI_NV_Read_Req(NV_SECTION_UI_FACTORYMODE, NV_FACTORYMODE_OFFSET, NV_FACTORYMODE_LEN, (uint8_t *)&nv_res);

    for(i = 0; i < AUTOTEST_ITEM_NUM; i++) {
        ext->test_res[i] = nv_res.test_res[i];
    }

    for(i = 0; i < AGINGTEST_ITEM_NUM; i++) {
        ext->agingtest_res[i] = nv_res.agingtest_res[i];
    }
}

void factorymode_save_test_res()
{
    uint8_t i = 0;
    nv_watch_factorymode_t nv_res;
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    memset(&nv_res, 0, NV_FACTORYMODE_LEN);
    for(i = 0; i < AUTOTEST_ITEM_NUM; i++) {
        nv_res.test_res[i] = ext->test_res[i];
    }

    for(i = 0; i < AGINGTEST_ITEM_NUM; i++) {
        nv_res.agingtest_res[i] = ext->agingtest_res[i];
    }
    UI_NV_Write_Req(NV_SECTION_UI_FACTORYMODE, NV_FACTORYMODE_OFFSET, NV_FACTORYMODE_LEN, (uint8_t *)&nv_res);
}


void factorymode_clear_test_res()
{
    uint8_t i = 0;
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    for(i = 0; i < AUTOTEST_ITEM_NUM; i++) {
        ext->test_res[i] = TEST_NOTDONE;
    }
    factorymode_save_test_res();
}

void factorymode_clear_agingtest_res()
{
    uint8_t i = 0;
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    for(i = 0; i < AGINGTEST_ITEM_NUM; i++) {
        ext->agingtest_res[i] = TEST_NOTDONE;
    }
    factorymode_save_test_res();
}

/*for camera driver test begin*/
static void camera_preview_test_task(lv_task_t * task)
{
    if(task == NULL) return;
    lv_factory_obj_ext_t * cameraext = factorymode_get_ext();
    if(Hal_Camera_Preview((uint8_t *)cameraext->img_camera.data)) {
        lv_obj_t *img = (lv_obj_t *)task->user_data;
        lv_img_set_src(img, &cameraext->img_camera);
    }
    lv_task_set_period(cameraext->preview_task, 30);
}

void camera_preview_test_start(void)
{
    lv_obj_t * obj = NULL;
    lv_obj_t * activity_obj =  lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN);
    if(lv_watch_get_top_activity_obj() != activity_obj)
        return;
    lv_watch_get_child_obj(activity_obj, lv_watch_obj_signal, &obj);

    cam_start_preview_t cam_params;

    cam_params.width = 240;
    cam_params.height = 240;
    cam_params.sensor_id = 0;
    Hal_Camera_Start_Preview(&cam_params);

    lv_factory_obj_ext_t * cameraext = factorymode_get_ext();
    cameraext->img_camera.header.always_zero = 0;
    cameraext->img_camera.header.w = LV_HOR_RES;
    cameraext->img_camera.header.h = LV_VER_RES;
    cameraext->img_camera.data_size = cameraext->img_camera.header.w * cameraext->img_camera.header.h * LV_COLOR_SIZE / 8;
    cameraext->img_camera.header.cf = LV_IMG_CF_TRUE_COLOR;
    cameraext->img_camera.data = lv_mem_alloc(cameraext->img_camera.header.w * cameraext->img_camera.header.h * LV_COLOR_SIZE / 8);
    LV_ASSERT_MEM(cameraext->img_camera.data);
    if(cameraext->img_camera.data == NULL) return;
    memset((void *)cameraext->img_camera.data, 0, cameraext->img_camera.header.w * cameraext->img_camera.header.h * LV_COLOR_SIZE / 8);
    lv_obj_t * img = lv_img_create(obj, NULL);
    lv_img_cache_invalidate_src(&cameraext->img_camera);
    lv_img_set_src(img, &cameraext->img_camera);

    cameraext->preview_task = lv_task_create(camera_preview_test_task, 100, LV_TASK_PRIO_HIGH, (void *)img);
}

void camera_preview_test_stop(void)
{
    lv_factory_obj_ext_t * cameraext = factorymode_get_ext();
    lv_obj_t * obj = NULL;
    Hal_Camera_Stop_Preview(0);
    lv_mem_free(cameraext->img_camera.data);
    cameraext->img_camera.data = NULL;
    lv_task_del(cameraext->preview_task);
    cameraext->preview_task = NULL;
    lv_watch_get_child_obj(lv_watch_get_activity_obj(ACT_ID_FACTORY_MODE_MAIN), lv_watch_obj_signal, &obj);
    lv_obj_del(lv_obj_get_child(obj, NULL));
}
/*for camera driver test end*/

/**********************
 *   STATIC FUNCTIONS
 **********************/
static void factorymode_main_prepare_destory(lv_obj_t * activity_obj)
{
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    lv_style_reset(&(ext->red_st));
    lv_style_reset(&(ext->green_st));
    lv_style_reset(&(ext->blue_st));
    lv_style_reset(&(ext->white_st));
    lv_style_reset(&(ext->gray_st));
    lv_style_reset(&(ext->list_btn_st));
    lv_style_reset(&(ext->orange_st));
    lv_style_reset(&(ext->purpul_st));
    lv_style_reset(&(ext->teal_st));
    lv_style_reset(&(ext->cyan_st));

    lv_watch_png_cache_all_free();

#if USE_LV_WATCH_ENGINEER_MODE != 0
    if(false == keep_screen_on_get_status()) {
        watch_set_suspend_enable(true, ACT_ID_FACTORY_MODE_MAIN, 0);
    }
#else
    watch_set_suspend_enable(true, ACT_ID_FACTORY_MODE_MAIN, 0);
#endif
}

static void factorymode_autotest_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_autotest_create(NULL);
}

static void factorymode_testreport_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_testreport_create(NULL);
}

#if USE_LV_WATCH_FACTORYMODE_AGING_MODE != 0
static void factorymode_agingmode_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_agingtest_create(NULL);
}
#endif

static void factorymode_factoryreset_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_reset_create(NULL);
}

#if USE_LV_WATCH_ENGINEER_MODE!= 0
static void factorymode_engineermode_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        engineer_mode_main_create(NULL);
}
#endif

#if USE_LV_WATCH_CTA!= 0
static void cta_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        cta_main_create(NULL);
}
#endif

#if USE_LV_WATCH_FACTORYMODE_GCF != 0
static void factorymode_gcf_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_gcf_create(NULL);
}
#endif

#if USE_LV_WATCH_FACTORYMODE_HWTEST != 0
static void factorymode_hwtest_create_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
    if(LV_EVENT_CLICKED == e)
        factorymode_hwtest_create(NULL);
}
#endif

static void factorymode_init_style(void)
{
    lv_factory_obj_ext_t * ext = factorymode_get_ext();

    lv_style_init(&(ext->white_st));
    lv_style_copy(&(ext->white_st), &lv_style_pretty);
    lv_style_set_text_font(&(ext->white_st), LV_STATE_DEFAULT, LV_THEME_WATCH_NIGHT_FONT_SMALL);
    lv_style_set_text_color(&(ext->white_st), LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_style_set_radius(&(ext->white_st), LV_STATE_DEFAULT, 0);
    lv_style_set_text_font(&(ext->white_st), LV_STATE_PRESSED, LV_THEME_WATCH_NIGHT_FONT_SMALL);
    lv_style_set_text_color(&(ext->white_st), LV_STATE_PRESSED, LV_COLOR_BLACK);
    lv_style_set_radius(&(ext->white_st), LV_STATE_PRESSED, 0);

    lv_style_init(&(ext->red_st));
    lv_style_copy(&(ext->red_st), &ext->white_st);
    lv_style_set_bg_color(&(ext->red_st), LV_STATE_DEFAULT, LV_COLOR_RED);
    lv_style_set_bg_grad_color(&(ext->red_st), LV_STATE_DEFAULT, LV_COLOR_RED);
    lv_style_set_bg_color(&(ext->red_st), LV_STATE_PRESSED, LV_COLOR_RED);
    lv_style_set_bg_grad_color(&(ext->red_st), LV_STATE_PRESSED, LV_COLOR_RED);

    lv_style_init(&(ext->green_st));
    lv_style_copy(&(ext->green_st), &ext->red_st);
    lv_style_set_bg_color(&(ext->green_st), LV_STATE_DEFAULT, LV_COLOR_GREEN);
    lv_style_set_bg_grad_color(&(ext->green_st), LV_STATE_DEFAULT, LV_COLOR_GREEN);
    lv_style_set_bg_color(&(ext->green_st), LV_STATE_PRESSED, LV_COLOR_GREEN);
    lv_style_set_bg_grad_color(&(ext->green_st), LV_STATE_PRESSED, LV_COLOR_GREEN);

    lv_style_init(&(ext->blue_st));
    lv_style_copy(&(ext->blue_st), &ext->red_st);
    lv_style_set_bg_color(&(ext->blue_st), LV_STATE_DEFAULT, LV_COLOR_BLUE);
    lv_style_set_bg_grad_color(&(ext->blue_st), LV_STATE_DEFAULT, LV_COLOR_BLUE);
    lv_style_set_bg_color(&(ext->blue_st), LV_STATE_PRESSED, LV_COLOR_BLUE);
    lv_style_set_bg_grad_color(&(ext->blue_st), LV_STATE_PRESSED, LV_COLOR_BLUE);


    lv_style_init(&(ext->gray_st));
    lv_style_copy(&(ext->gray_st), &(ext->green_st));
    lv_style_set_bg_color(&(ext->gray_st), LV_STATE_DEFAULT, LV_COLOR_MAKE(0x20, 0x20, 0x20));
    lv_style_set_bg_grad_color(&(ext->gray_st), LV_STATE_DEFAULT, LV_COLOR_MAKE(0x20, 0x20, 0x20));
    lv_style_set_text_color(&(ext->gray_st), LV_STATE_DEFAULT, LV_COLOR_GRAY);

    lv_style_init(&(ext->orange_st));
    lv_style_copy(&(ext->orange_st), &(ext->red_st));
    lv_style_set_bg_color(&(ext->orange_st), LV_STATE_DEFAULT, LV_COLOR_ORANGE);
    lv_style_set_bg_grad_color(&(ext->orange_st), LV_STATE_DEFAULT, LV_COLOR_ORANGE);
    lv_style_set_bg_color(&(ext->orange_st), LV_STATE_PRESSED, LV_COLOR_ORANGE);
    lv_style_set_bg_grad_color(&(ext->orange_st), LV_STATE_PRESSED, LV_COLOR_ORANGE);

    lv_style_init(&(ext->purpul_st));
    lv_style_copy(&(ext->purpul_st), &(ext->red_st));
    lv_style_set_bg_color(&(ext->purpul_st), LV_STATE_DEFAULT, LV_COLOR_PURPLE);
    lv_style_set_bg_grad_color(&(ext->purpul_st), LV_STATE_DEFAULT, LV_COLOR_PURPLE);
    lv_style_set_bg_color(&(ext->purpul_st), LV_STATE_PRESSED, LV_COLOR_PURPLE);
    lv_style_set_bg_grad_color(&(ext->purpul_st), LV_STATE_PRESSED, LV_COLOR_PURPLE);

    lv_style_init(&(ext->teal_st));
    lv_style_copy(&(ext->teal_st), &(ext->red_st));
    lv_style_set_bg_color(&(ext->teal_st), LV_STATE_DEFAULT, LV_COLOR_TEAL);
    lv_style_set_bg_grad_color(&(ext->teal_st), LV_STATE_DEFAULT, LV_COLOR_TEAL);
    lv_style_set_bg_color(&(ext->teal_st), LV_STATE_PRESSED, LV_COLOR_TEAL);
    lv_style_set_bg_grad_color(&(ext->teal_st), LV_STATE_PRESSED, LV_COLOR_TEAL);

    lv_style_init(&(ext->cyan_st));
    lv_style_copy(&(ext->cyan_st), &(ext->red_st));
    lv_style_set_bg_color(&(ext->cyan_st), LV_STATE_DEFAULT, LV_COLOR_CYAN);
    lv_style_set_bg_grad_color(&(ext->cyan_st), LV_STATE_DEFAULT, LV_COLOR_CYAN);
    lv_style_set_bg_color(&(ext->cyan_st), LV_STATE_PRESSED, LV_COLOR_CYAN);
    lv_style_set_bg_grad_color(&(ext->cyan_st), LV_STATE_PRESSED, LV_COLOR_CYAN);

    lv_style_init(&(ext->list_btn_st));
    lv_style_copy(&(ext->list_btn_st), &lv_watch_style_transp);
    lv_style_set_radius(&(ext->list_btn_st), LV_STATE_DEFAULT, 0);
    lv_style_set_border_width(&(ext->list_btn_st), LV_STATE_DEFAULT, 1);
    lv_style_set_border_color(&(ext->list_btn_st), LV_STATE_DEFAULT, LV_COLOR_WHITE);
    lv_style_set_border_side(&(ext->list_btn_st), LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM);
    lv_style_set_radius(&(ext->list_btn_st), LV_STATE_PRESSED, 0);
    lv_style_set_border_width(&(ext->list_btn_st), LV_STATE_PRESSED, 1);
    lv_style_set_border_color(&(ext->list_btn_st), LV_STATE_PRESSED, LV_COLOR_WHITE);
    lv_style_set_border_side(&(ext->list_btn_st), LV_STATE_PRESSED, LV_BORDER_SIDE_BOTTOM);
    lv_style_set_radius(&(ext->list_btn_st), LV_STATE_FOCUSED, 0);
    lv_style_set_border_width(&(ext->list_btn_st), LV_STATE_FOCUSED, 1);
    lv_style_set_border_color(&(ext->list_btn_st), LV_STATE_FOCUSED, LV_COLOR_WHITE);
    lv_style_set_border_side(&(ext->list_btn_st), LV_STATE_FOCUSED, LV_BORDER_SIDE_BOTTOM);
}

static void factorymode_init_testmodule(void)
{
    lv_factory_obj_ext_t * ext = factorymode_get_ext();
    for(uint8_t i = 0; i < AUTOTEST_ITEM_NUM; i++)
        ext->istest[i] = false;
#if FACTORY_MODE_VERSION_INFO != 0
    ext->istest[AUTOTEST_VERSION_INFO] = true;
#endif

#if FACTORY_MODE_KEY != 0
    ext->istest[AUTOTEST_PRESS_KEY] = true;
#endif

#if FACTORY_MODE_LCD_TOUCH != 0
    ext->istest[AUTOTEST_LCD_TOUCH] = true;
#endif

#if FACTORY_MODE_LCD_COLOR != 0
    ext->istest[AUTOTEST_LCD_COLOR] = true;
#endif

#if FACTORY_MODE_CAMERA != 0
    ext->istest[AUTOTEST_CAMERA] = true;
#endif

#if FACTORY_MODE_WIFI != 0
    ext->istest[AUTOTEST_WIFI] = true;
#endif

#if FACTORY_MODE_GPS != 0
    ext->istest[AUTOTEST_GPS] = true;
#endif

#if FACTORY_MODE_SPEAKER != 0
    ext->istest[AUTOTEST_SPEAKER] = true;
#endif

#if FACTORY_MODE_MICPHONE != 0
    ext->istest[AUTOTEST_MICPHONE] = true;
#endif

#if FACTORY_MODE_SIMCARD != 0
    ext->istest[AUTOTEST_SIMCARD] = true;
#endif

#if FACTORY_MODE_CALL != 0
    ext->istest[AUTOTEST_CALL] = true;
#endif

#if FACTORY_MODE_MEMORY!= 0
    ext->istest[AUTOTEST_MEMORY] = true;
#endif

#if FACTORY_MODE_BACKLIGHT != 0
    ext->istest[AUTOTEST_BACKLIGHT] = true;
#endif

#if FACTORY_MODE_GRAVITY != 0
    ext->istest[AUTOTEST_GRAVITY] = true;
#endif

#if FACTORY_MODE_BATTERY != 0
    ext->istest[AUTOTEST_BATTERY] = true;
#endif

#if FACTORY_MODE_VIBRATION != 0
    ext->istest[AUTOTEST_VIBRATION] = true;
#endif
}

#endif /*USE_LV_WATCH_FACTORY_MODE*/
